<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>人员结构分析RP图</title>
    <script src="../public/js/tailwindcss3.4.16"></script>
    <link href="../font-awesome/css/all.min.css" rel="stylesheet">
    <script src="../chart.umd.min.js"></script>
    <script src="../public/js/moment.min.js"></script>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#3B82F6',
                        secondary: '#10B981',
                        accent: '#8B5CF6',
                        dark: '#1E293B',
                        light: '#F8FAFC'
                    },
                    fontFamily: {
                        sans: ['Inter', 'system-ui', 'sans-serif'],
                    },
                }
            }
        }
    </script>
    <style type="text/tailwindcss">
        @layer utilities {
            .content-auto {
                content-visibility: auto;
            }
            .card-shadow {
                box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
            }
            .gradient-bg {
                background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
            }
            .stat-card {
                @apply bg-white rounded-xl p-6 transition-all duration-300 hover:shadow-lg border border-gray-100;
            }
            .chart-container {
                @apply bg-white rounded-xl p-4 shadow-sm border border-gray-100;
            }
            .highlight-card {
                @apply bg-blue-50 border-blue-100;
            }
            .warning-card {
                @apply bg-orange-50 border-orange-100;
            }
            .success-card {
                @apply bg-green-50 border-green-100;
            }
        }
    </style>
</head>
<body class="bg-gray-50 font-sans text-dark">
    <div class="container mx-auto px-4 py-8 max-w-7xl">
        <header class="mb-8">
            <h1 class="text-[clamp(1.75rem,3vw,2.5rem)] font-bold text-dark mb-2 flex items-center">
                <i class="fa fa-users text-primary mr-3"></i>人员结构分析报告
            </h1>
            <p class="text-gray-600 text-lg">基于多维度的人员构成分析与评估</p>
        </header>

        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
            <div class="stat-card">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="font-semibold text-lg">总人数</h3>
                    <span class="text-xs bg-blue-100 text-primary px-2 py-1 rounded-full">截至2025</span>
                </div>
                <div class="flex items-end">
                    <span class="text-4xl font-bold">328</span>
                    <span class="text-green-500 ml-2 flex items-center text-sm">
                        <i class="fa fa-arrow-up mr-1"></i>12.5%
                    </span>
                </div>
                <p class="text-gray-500 text-sm mt-1">较上一年度增长36人</p>
            </div>

            <div class="stat-card">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="font-semibold text-lg">平均年龄</h3>
                    <span class="text-xs bg-blue-100 text-primary px-2 py-1 rounded-full">岁</span>
                </div>
                <div class="flex items-end">
                    <span class="text-4xl font-bold">38.6</span>
                    <span class="text-orange-500 ml-2 flex items-center text-sm">
                        <i class="fa fa-arrow-up mr-1"></i>1.2
                    </span>
                </div>
                <p class="text-gray-500 text-sm mt-1">较上一年度略有上升</p>
            </div>

            <div class="stat-card">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="font-semibold text-lg">硕士以上比例</h3>
                    <span class="text-xs bg-blue-100 text-primary px-2 py-1 rounded-full">占比</span>
                </div>
                <div class="flex items-end">
                    <span class="text-4xl font-bold">47%</span>
                    <span class="text-green-500 ml-2 flex items-center text-sm">
                        <i class="fa fa-arrow-up mr-1"></i>3%
                    </span>
                </div>
                <p class="text-gray-500 text-sm mt-1">较上一年度提升3个百分点</p>
            </div>

            <div class="stat-card">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="font-semibold text-lg">党员比例</h3>
                    <span class="text-xs bg-blue-100 text-primary px-2 py-1 rounded-full">占比</span>
                </div>
                <div class="flex items-end">
                    <span class="text-4xl font-bold">62%</span>
                    <span class="text-green-500 ml-2 flex items-center text-sm">
                        <i class="fa fa-check mr-1"></i>达标
                    </span>
                </div>
                <p class="text-gray-500 text-sm mt-1">满足军工企业要求(>60%)</p>
            </div>
        </div>

        <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
            <div class="stat-card">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="font-semibold text-lg">学历分布</h3>
                    <span class="text-xs bg-blue-100 text-primary px-2 py-1 rounded-full">硕士以上占47%</span>
                </div>
                <div class="h-64">
                    <canvas id="educationChart"></canvas>
                </div>
                <div class="mt-4 grid grid-cols-2 gap-2">
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-primary mr-2"></span>
                        <span class="text-sm">博士(12%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-blue-400 mr-2"></span>
                        <span class="text-sm">硕士(35%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-blue-200 mr-2"></span>
                        <span class="text-sm">本科(48%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-blue-100 mr-2"></span>
                        <span class="text-sm">大专及以下(5%)</span>
                    </div>
                </div>
            </div>

            <div class="stat-card">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="font-semibold text-lg">年龄结构</h3>
                    <span class="text-xs bg-orange-100 text-orange-600 px-2 py-1 rounded-full">35岁以下需加强</span>
                </div>
                <div class="h-64">
                    <canvas id="ageChart"></canvas>
                </div>
                <div class="mt-4 grid grid-cols-2 gap-2">
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-orange-500 mr-2"></span>
                        <span class="text-sm">25-35岁(40%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-orange-300 mr-2"></span>
                        <span class="text-sm">36-45岁(35%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-orange-100 mr-2"></span>
                        <span class="text-sm">46岁以上(25%)</span>
                    </div>
                </div>
            </div>

            <div class="stat-card">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="font-semibold text-lg">政治面貌</h3>
                    <span class="text-xs bg-green-100 text-green-600 px-2 py-1 rounded-full">党员比例达标</span>
                </div>
                <div class="h-64">
                    <canvas id="politicalChart"></canvas>
                </div>
                <div class="mt-4 grid grid-cols-2 gap-2">
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-green-500 mr-2"></span>
                        <span class="text-sm">党员(62%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-green-300 mr-2"></span>
                        <span class="text-sm">民主党派(8%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-green-100 mr-2"></span>
                        <span class="text-sm">群众(30%)</span>
                    </div>
                </div>
            </div>
        </div>

        <div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
            <div class="stat-card">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="font-semibold text-lg">入职年限</h3>
                    <span class="text-xs bg-purple-100 text-purple-600 px-2 py-1 rounded-full">3-5年占比最高</span>
                </div>
                <div class="h-64">
                    <canvas id="tenureChart"></canvas>
                </div>
                <div class="mt-4 grid grid-cols-2 gap-2">
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-purple-500 mr-2"></span>
                        <span class="text-sm">1年以下(10%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-purple-400 mr-2"></span>
                        <span class="text-sm">1-3年(25%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-purple-300 mr-2"></span>
                        <span class="text-sm">3-5年(50%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-purple-200 mr-2"></span>
                        <span class="text-sm">5年以上(15%)</span>
                    </div>
                </div>
            </div>

            <div class="stat-card">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="font-semibold text-lg">岗位分布</h3>
                    <span class="text-xs bg-teal-100 text-teal-600 px-2 py-1 rounded-full">技术岗位为主</span>
                </div>
                <div class="h-64">
                    <canvas id="positionChart"></canvas>
                </div>
                <div class="mt-4 grid grid-cols-2 gap-2">
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-teal-500 mr-2"></span>
                        <span class="text-sm">技术(45%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-teal-400 mr-2"></span>
                        <span class="text-sm">管理(20%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-teal-300 mr-2"></span>
                        <span class="text-sm">行政(15%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-teal-200 mr-2"></span>
                        <span class="text-sm">营销(20%)</span>
                    </div>
                </div>
            </div>

            <div class="stat-card">
                <div class="flex items-center justify-between mb-4">
                    <h3 class="font-semibold text-lg">专业匹配度</h3>
                    <span class="text-xs bg-amber-100 text-amber-600 px-2 py-1 rounded-full">整体良好</span>
                </div>
                <div class="h-64">
                    <canvas id="majorMatchChart"></canvas>
                </div>
                <div class="mt-4 grid grid-cols-2 gap-2">
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-amber-500 mr-2"></span>
                        <span class="text-sm">完全匹配(40%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-amber-400 mr-2"></span>
                        <span class="text-sm">基本匹配(45%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-amber-300 mr-2"></span>
                        <span class="text-sm">部分匹配(10%)</span>
                    </div>
                    <div class="flex items-center">
                        <span class="w-3 h-3 rounded-full bg-amber-200 mr-2"></span>
                        <span class="text-sm">不匹配(5%)</span>
                    </div>
                </div>
            </div>
        </div>

        <div class="chart-container mb-8">
            <div class="flex items-center justify-between mb-4">
                <h3 class="font-semibold text-lg">部门人员密度分析</h3>
                <div class="flex space-x-2">
                    <button id="btnDepartment" class="px-3 py-1 text-sm bg-primary text-white rounded-md">按部门</button>
                    <button id="btnPosition" class="px-3 py-1 text-sm bg-gray-200 text-gray-700 rounded-md">按岗位</button>
                    <button id="btnAge" class="px-3 py-1 text-sm bg-gray-200 text-gray-700 rounded-md">按年龄</button>
                </div>
            </div>
            <div class="h-80">
                <canvas id="densityChart"></canvas>
            </div>
        </div>

        <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
            <div class="stat-card highlight-card">
                <div class="flex items-center mb-3">
                    <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center text-primary">
                        <i class="fa fa-check-circle"></i>
                    </div>
                    <h3 class="font-semibold ml-3">学历优势</h3>
                </div>
                <p class="text-gray-700">硕士以上学历占比47%，满足高技术研发需求，为企业技术创新提供有力支撑。</p>
            </div>

            <div class="stat-card warning-card">
                <div class="flex items-center mb-3">
                    <div class="w-10 h-10 rounded-full bg-orange-100 flex items-center justify-center text-orange-500">
                        <i class="fa fa-exclamation-triangle"></i>
                    </div>
                    <h3 class="font-semibold ml-3">年龄短板</h3>
                </div>
                <p class="text-gray-700">35岁以下员工占比40%，比例不足，需加强青年人才引进，优化年龄梯队建设。</p>
            </div>

            <div class="stat-card success-card">
                <div class="flex items-center mb-3">
                    <div class="w-10 h-10 rounded-full bg-green-100 flex items-center justify-center text-green-500">
                        <i class="fa fa-shield"></i>
                    </div>
                    <h3 class="font-semibold ml-3">政治达标</h3>
                </div>
                <p class="text-gray-700">党员比例达到62%，超过军工企业要求的60%标准，满足企业特殊政治要求。</p>
            </div>
        </div>

        <div class="bg-white rounded-xl p-6 shadow-sm border border-gray-100">
            <h3 class="font-semibold text-lg mb-4">分析结论与建议</h3>
            <div class="space-y-4">
                <div class="flex">
                    <div class="text-primary font-bold mr-3">▶</div>
                    <p class="text-gray-700">人员学历结构良好，硕士以上学历占比较高，建议持续保持高端人才的引进和培养，发挥技术优势。</p>
                </div>
                <div class="flex">
                    <div class="text-orange-500 font-bold mr-3">▶</div>
                    <p class="text-gray-700">年龄结构需优化，建议加大青年人才招聘力度，制定针对性的人才吸引政策，完善人才梯队建设。</p>
                </div>
                <div class="flex">
                    <div class="text-green-500 font-bold mr-3">▶</div>
                    <p class="text-gray-700">政治面貌比例符合军工企业要求，建议继续加强党建工作，保持党员队伍的先进性和纯洁性。</p>
                </div>
                <div class="flex">
                    <div class="text-purple-500 font-bold mr-3">▶</div>
                    <p class="text-gray-700">3-5年工龄员工占比最高，形成了较为稳定的核心团队，但需关注新老员工交替问题，做好人才储备。</p>
                </div>
                <div class="flex">
                    <div class="text-teal-500 font-bold mr-3">▶</div>
                    <p class="text-gray-700">技术岗位人员充足，但需关注跨部门协作和技术创新能力的提升，培养复合型人才。</p>
                </div>
                <div class="flex">
                    <div class="text-amber-500 font-bold mr-3">▶</div>
                    <p class="text-gray-700">专业匹配度整体良好，建议进一步加强员工职业规划和培训，提高专业技能与岗位需求的契合度。</p>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 学历分布数据
        const educationData = {
            labels: ['博士', '硕士', '本科', '大专及以下'],
            datasets: [{
                data: [12, 35, 48, 5],
                backgroundColor: [
                    '#3B82F6', // primary
                    '#60A5FA', // blue-400
                    '#BFDBFE', // blue-200
                    '#DBEAFE', // blue-100
                ],
                borderWidth: 0,
                hoverOffset: 10
            }]
        };

        // 年龄结构数据
        const ageData = {
            labels: ['25-35岁', '36-45岁', '46岁以上'],
            datasets: [{
                data: [40, 35, 25],
                backgroundColor: [
                    '#F97316', // orange-500
                    '#FDBA74', // orange-300
                    '#FFEDD5', // orange-100
                ],
                borderWidth: 0,
                hoverOffset: 10
            }]
        };

        // 政治面貌数据
        const politicalData = {
            labels: ['党员', '民主党派', '群众'],
            datasets: [{
                data: [62, 8, 30],
                backgroundColor: [
                    '#10B981', // green-500
                    '#6EE7B7', // green-300
                    '#D1FAE5', // green-100
                ],
                borderWidth: 0,
                hoverOffset: 10
            }]
        };

        // 入职年限数据
        const tenureData = {
            labels: ['1年以下', '1-3年', '3-5年', '5年以上'],
            datasets: [{
                data: [10, 25, 50, 15],
                backgroundColor: [
                    '#A855F7', // purple-500
                    '#C084FC', // purple-400
                    '#D8B4FE', // purple-300
                    '#E9D5FF', // purple-200
                ],
                borderWidth: 0,
                hoverOffset: 10
            }]
        };

        // 岗位分布数据
        const positionData = {
            labels: ['技术', '管理', '行政', '营销'],
            datasets: [{
                data: [45, 20, 15, 20],
                backgroundColor: [
                    '#14B8A6', // teal-500
                    '#2DD4BF', // teal-400
                    '#5EEAD4', // teal-300
                    '#99F6E4', // teal-200
                ],
                borderWidth: 0,
                hoverOffset: 10
            }]
        };

        // 专业匹配度数据
        const majorMatchData = {
            labels: ['完全匹配', '基本匹配', '部分匹配', '不匹配'],
            datasets: [{
                data: [40, 45, 10, 5],
                backgroundColor: [
                    '#F59E0B', // amber-500
                    '#FBBF24', // amber-400
                    '#FCD34D', // amber-300
                    '#FDE68A', // amber-200
                ],
                borderWidth: 0,
                hoverOffset: 10
            }]
        };

        // 部门人员密度数据
        const departmentDensityData = {
            labels: ['研发部', '市场部', '财务部', '人力资源部', '行政部', '生产部', '质量部'],
            datasets: [
                {
                    label: '人员数量',
                    data: [85, 42, 25, 20, 18, 95, 43],
                    backgroundColor: '#3B82F6',
                    borderRadius: 4
                },
                {
                    label: '平均年龄',
                    data: [36, 32, 41, 38, 45, 39, 37],
                    backgroundColor: '#F97316',
                    borderRadius: 4
                },
                {
                    label: '硕士以上比例',
                    data: [65, 30, 25, 40, 15, 20, 35],
                    backgroundColor: '#10B981',
                    borderRadius: 4
                }
            ]
        };

        // 按岗位的人员密度数据
        const positionDensityData = {
            labels: ['技术', '管理', '行政', '营销', '生产', '质量', '财务', '人力资源'],
            datasets: [
                {
                    label: '人员数量',
                    data: [148, 45, 35, 55, 95, 43, 25, 20],
                    backgroundColor: '#3B82F6',
                    borderRadius: 4
                },
                {
                    label: '平均年龄',
                    data: [34, 42, 44, 33, 40, 38, 41, 38],
                    backgroundColor: '#F97316',
                    borderRadius: 4
                },
                {
                    label: '硕士以上比例',
                    data: [60, 45, 20, 25, 15, 25, 30, 35],
                    backgroundColor: '#10B981',
                    borderRadius: 4
                }
            ]
        };

        // 按年龄的人员密度数据
        const ageDensityData = {
            labels: ['25-30岁', '31-35岁', '36-40岁', '41-45岁', '46-50岁', '51岁以上'],
            datasets: [
                {
                    label: '人员数量',
                    data: [58, 74, 60, 58, 35, 43],
                    backgroundColor: '#3B82F6',
                    borderRadius: 4
                },
                {
                    label: '硕士以上比例',
                    data: [55, 60, 45, 35, 25, 15],
                    backgroundColor: '#10B981',
                    borderRadius: 4
                },
                {
                    label: '党员比例',
                    data: [45, 50, 70, 80, 85, 90],
                    backgroundColor: '#A855F7',
                    borderRadius: 4
                }
            ]
        };

        // 图表配置
        const chartConfig = {
            responsive: true,
            maintainAspectRatio: false,
            plugins: {
                legend: {
                    display: false
                },
                tooltip: {
                    backgroundColor: 'rgba(0, 0, 0, 0.7)',
                    padding: 10,
                    cornerRadius: 6,
                    titleFont: {
                        size: 14,
                        weight: 'bold'
                    },
                    bodyFont: {
                        size: 13
                    }
                }
            }
        };

        // 创建学历图表
        const educationChart = new Chart(
            document.getElementById('educationChart'),
            {
                type: 'doughnut',
                data: educationData,
                options: {
                    ...chartConfig,
                    cutout: '70%',
                    animation: {
                        animateRotate: true,
                        animateScale: true
                    }
                }
            }
        );

        // 创建年龄图表
        const ageChart = new Chart(
            document.getElementById('ageChart'),
            {
                type: 'doughnut',
                data: ageData,
                options: {
                    ...chartConfig,
                    cutout: '70%',
                    animation: {
                        animateRotate: true,
                        animateScale: true
                    }
                }
            }
        );

        // 创建政治面貌图表
        const politicalChart = new Chart(
            document.getElementById('politicalChart'),
            {
                type: 'doughnut',
                data: politicalData,
                options: {
                    ...chartConfig,
                    cutout: '70%',
                    animation: {
                        animateRotate: true,
                        animateScale: true
                    }
                }
            }
        );

        // 创建入职年限图表
        const tenureChart = new Chart(
            document.getElementById('tenureChart'),
            {
                type: 'doughnut',
                data: tenureData,
                options: {
                    ...chartConfig,
                    cutout: '70%',
                    animation: {
                        animateRotate: true,
                        animateScale: true
                    }
                }
            }
        );

        // 创建岗位分布图表
        const positionChart = new Chart(
            document.getElementById('positionChart'),
            {
                type: 'doughnut',
                data: positionData,
                options: {
                    ...chartConfig,
                    cutout: '70%',
                    animation: {
                        animateRotate: true,
                        animateScale: true
                    }
                }
            }
        );

        // 创建专业匹配度图表
        const majorMatchChart = new Chart(
            document.getElementById('majorMatchChart'),
            {
                type: 'doughnut',
                data: majorMatchData,
                options: {
                    ...chartConfig,
                    cutout: '70%',
                    animation: {
                        animateRotate: true,
                        animateScale: true
                    }
                }
            }
        );

        // 创建部门人员密度图表
        let densityChart = new Chart(
            document.getElementById('densityChart'),
            {
                type: 'bar',
                data: departmentDensityData,
                options: {
                    ...chartConfig,
                    scales: {
                        x: {
                            grid: {
                                display: false
                            }
                        },
                        y: {
                            beginAtZero: true,
                            grid: {
                                color: 'rgba(0, 0, 0, 0.05)'
                            }
                        }
                    },
                    animation: {
                        duration: 2000
                    },
                    plugins: {
                        legend: {
                            display: true,
                            position: 'bottom',
                            labels: {
                                boxWidth: 12,
                                padding: 15
                            }
                        }
                    },
                    barPercentage: 0.6,
                    categoryPercentage: 0.7
                }
            }
        );

        // 按钮切换功能
        document.getElementById('btnDepartment').addEventListener('click', function() {
            updateDensityChart('department');
            setActiveButton(this);
        });

        document.getElementById('btnPosition').addEventListener('click', function() {
            updateDensityChart('position');
            setActiveButton(this);
        });

        document.getElementById('btnAge').addEventListener('click', function() {
            updateDensityChart('age');
            setActiveButton(this);
        });

        function setActiveButton(button) {
            // 移除所有按钮的激活状态
            document.querySelectorAll('#btnDepartment, #btnPosition, #btnAge').forEach(btn => {
                btn.classList.remove('bg-primary', 'text-white');
                btn.classList.add('bg-gray-200', 'text-gray-700');
            });
            // 设置当前按钮为激活状态
            button.classList.remove('bg-gray-200', 'text-gray-700');
            button.classList.add('bg-primary', 'text-white');
        }

        function updateDensityChart(type) {
            let newData;
            let newOptions;

            if (type === 'department') {
                newData = departmentDensityData;
                newOptions = {
                    ...densityChart.options,
                    scales: {
                        x: {
                            grid: {
                                display: false
                            }
                        },
                        y: {
                            beginAtZero: true,
                            grid: {
                                color: 'rgba(0, 0, 0, 0.05)'
                            }
                        }
                    }
                };
            } else if (type === 'position') {
                newData = positionDensityData;
                newOptions = {
                    ...densityChart.options,
                    scales: {
                        x: {
                            grid: {
                                display: false
                            }
                        },
                        y: {
                            beginAtZero: true,
                            grid: {
                                color: 'rgba(0, 0, 0, 0.05)'
                            }
                        }
                    }
                };
            } else if (type === 'age') {
                newData = ageDensityData;
                newOptions = {
                    ...densityChart.options,
                    scales: {
                        x: {
                            grid: {
                                display: false
                            }
                        },
                        y: {
                            beginAtZero: true,
                            grid: {
                                color: 'rgba(0, 0, 0, 0.05)'
                            }
                        }
                    }
                };
            }

            // 更新图表
            densityChart.data = newData;
            densityChart.options = newOptions;
            densityChart.update();
        }
    </script>
</body>
</html>